import 'package:flutter/material.dart';

class EgListView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<Widget> listTitles = <Widget>[
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
        trailing: new Icon(Icons.ac_unit),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
      new ListTile(
        title: new Text(
          "北京市海淀区上地街道山地五街九号，方正大厦",
          style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
        ),
        subtitle: new Text("方正大厦主楼，三楼 321"),
        leading: new Icon(
          Icons.fastfood,
          color: Colors.blue,
        ),
      ),
    ];

    return new Scaffold(
      appBar: new AppBar(
        title: new Text("ListView ListTitle"),
      ),
      body: new ListView(
        children: listTitles,
      ),
    );
  }
}

class EgListText extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("长文本ListView"),
      ),
      body: new ListView(
        children: <Widget>[
          new Center(
            child: new Text(
              "还在用Parcelable?",
              style: new TextStyle(fontSize: 30),
            ),
          ),
          new Center(
            child: new Text(
              "Parcelize已经来了",
              style: new TextStyle(fontSize: 16),
            ),
          ),
          new Center(child: new Text('''
            嗨，大家好，欢迎来到系列文章的第五篇，在这里我们将研究在Kotlin中处理Parcelable对象。前面文章我们研究了data class这里我们将data class继承Parcelable接口。
使用Parcelable最常见的场景是将一个数据模型从一个Activity传递给另外一个Activity。当传递基本数据类型没什么问题，但是要传递自定义的对象，那么我们需要做一些操作：

Parcelable是最好的方案但是它包含很多模板代码，因此每次更细数据模型的时候我们都要编写和更新代码。在Java中我们可以使用AutoValue来避免模板代码，但是Kotlin呢？
下面我们看下怎样将前篇文章中的Person类实现Parcelable，一行代码的Person类：
            '''))
        ],
      ),
    );
  }
}

class EgListViewBuild extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var list = <String>[
      "dsadsa",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "dsdd",
      "123132132",
      "456465465",
      "789789798798"
    ];

    return new Scaffold(
      appBar: new AppBar(title: new Text("演示ListViewBuilder")),
      body: new ListView.builder(
          itemBuilder: (BuildContext context, int index) {
            return new Container(
              height: 45,
              padding: EdgeInsets.all(20),
              child: new Center(
                child: new Text(
                  list[index],
                  style: TextStyle(fontSize: 18, color: Colors.teal),
                ),
              ),
            );
          },
          itemCount: list.length),
    );
  }
}
